<!DOCTYPE html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<base href="<%=basePath %>"/>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>云谷CMS</title>
    <!--Import Google Icon Font-->
    <!--Import materialize.css-->


    <meta charset="UTF-8">
    <title>Basic CRUD Application - jQuery EasyUI CRUD Demo</title>
    <link rel="stylesheet" type="text/css" href="/lib/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/lib/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="/lib/easyui/themes/color.css">

    <script type="text/javascript" src="/lib/jquery-1.6.min.js"></script>
    <script type="text/javascript" src="/lib/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/lib/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/lib/jquery.md5.js"></script>
    <script type="text/javascript" src="/lib/ztree/js/jquery.ztree.all.min.js"></script>
</head>
</head>

<body style="background-color: #0d71bb;">
<div style="margin:auto;width: 600px;height: 480px;margin-top: 240px;">
    <div class="easyui-panel" title="云谷CMS登录" style="width:100%;max-width:400px;padding:30px 60px;">
        <form id="loginForm" method="post">
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" name="username" value="${username}" style="width:100%"
                       data-options="label:'用户名:',required:true">
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-passwordbox" name="password" value="${password}" style="width:100%"
                       data-options="label:'密码:',required:true">
            </div>

        </form>
        <div style="text-align:center;padding:5px 0">
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" style="width:80px">登录</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()" style="width:80px">重置</a>
        </div>
    </div>
</div>
<script>
    $(function () {
        var msg = "${msg}";
        if (msg != null && msg != "" && msg != undefined) {
            $.messager.alert('登录提示', msg);
        }
    });
    function submitForm() {

        $('#loginForm').form('submit', {
            url: "<%=basePath %>/doLogin",
            method: "post",
            onSubmit: function () {
                $("input[name=password]").val($.md5($("input[name=passowrd]").val()));
                return true;
            },
            success: function (data) {
                var obj = JSON.parse(data);
                if (obj.success) {
                    window.location.href = "admin/main";
                } else {
                    $.messager.alert('登录提示', obj.message);
                    $('#loginForm').form('clear');
                }
            }
        });
    }
    ;
    function clearForm() {
        $('#loginForm').form('clear');
    }
</script>
<!--Import jQuery before materialize.js-->
<script>
    $(function () {

    });
</script>
</body>
</html>
